﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    class DeleteFriendsAction : AuthPostAction<Params.DeleteFriendsParams,
        Results.DeleteFriendsResult>
    {
        protected override ActionResult<Results.DeleteFriendsResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            Params.DeleteFriendsParams opParams)
        {
            ServiceResult<UserRelation> serviceResult = new FriendsService().Delete(context.AccountId,
                opParams.TargetUserId);

            Results.DeleteFriendsResult actionResult = new Results.DeleteFriendsResult();

            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.DeleteFriendsResult>(true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.DeleteFriendsResult>(false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
